import { PrivateRoutes } from "src/router/routes";

export const RouterParser = (menuData) => {
  const result = [];
  for (let item of menuData) {
    if (item.need_by_router) {
      const obj = {
        path: item.path,
        name: item.route_name,
        component: item.component,
        meta: {
          component_name: item.component_name,
          menu_code: item.menu_code,
          ...item.meta,
        },
      };
      result.push(obj);
    }
  }
  // 将需要鉴权路由的children（默认是空的）替换成后台传过来的整理后的路由表

  PrivateRoutes[0].children = [...result];
  // 返回鉴权路由
  return PrivateRoutes;
};
